#!/bin/sh

TTY=
echo $GLOBAL_BASE_BOOTARGS | grep console= ||
  TTY='console=tty1'

# installkernel relies on existing extlinux.conf
# with filled in `default' label
mkdir -p /boot/extlinux
cat > /boot/extlinux/extlinux.conf << EOF
menu title ALTLinux Boot Options

default linux
timeout $GLOBAL_UBOOT_TIMEOUT

label linux
	kernel ../vmlinuz
	initrd ../initrd.img
	fdtdir ../dtb
	append root=LABEL=ROOT ro $GLOBAL_BASE_BOOTARGS $GLOBAL_UBOOT_BOOTARGS $TTY
EOF

[ -z "${GLOBAL_UBOOT_NOFDTDIR:-}" ] || sed -i -e '/^[\t]*fdtdir \/boot\/dtb$/d' /boot/extlinux/extlinux.conf
